package com.csweimei.rentmanagementtreasure.tenant.ui.act.house;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProviders;

import com.chad.library.BR;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.base.AppConfig;
import com.csweimei.rentmanagementtreasure.base.AppViewModelFactory;
import com.csweimei.rentmanagementtreasure.databinding.ActivityAddHouseHzBinding;
import com.csweimei.rentmanagementtreasure.http.postBean.PostHouseHzBean;
import com.csweimei.rentmanagementtreasure.tenant.viewModel.AddHouseHzVm;

import me.goldze.mvvmhabit.base.BaseActivity;

public class AddHouseHzActivity extends BaseActivity<ActivityAddHouseHzBinding, AddHouseHzVm> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_add_house_hz;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setActivity(this);
        viewModel.setBanner(binding.banner);
    }

    @Override
    public AddHouseHzVm initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this,factory).get(AddHouseHzVm.class);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 10087){
            PostHouseHzBean postHouseHzBean = (PostHouseHzBean) data.getSerializableExtra(AppConfig.BUNDLE_KEY);
            viewModel.postBean.set(postHouseHzBean);
        }
        if (resultCode == 10088){
            PostHouseHzBean postHouseHzBean = (PostHouseHzBean) data.getSerializableExtra(AppConfig.BUNDLE_KEY);
            viewModel.postBean.set(postHouseHzBean);
        }

    }
}